Remove deprecated tooltips, use new tooltips API. (#449311, Jan Arne
authorMatthias Clasen <mclasen@redhat.com>
Mon, 9 Jul 2007 20:32:35 +0000 (20:32 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 9 Jul 2007 20:32:35 +0000 (20:32 +0000)
2007-07-09  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkvolumebutton.c: Remove deprecated tooltips,
        use new tooltips API.  (#449311, Jan Arne Petersen)

svn path=/trunk/; revision=18424

ChangeLog
gtk/gtkvolumebutton.c

index b257b2938b3ec7657e808ed08e7cf4046bfbaa9b..c8ba8f4d0542271be370ba68d50e43245799444d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-09  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkvolumebutton.c: Remove deprecated tooltips,
+       use new tooltips API.  (#449311, Jan Arne Petersen)
+
 2007-07-09  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkselection.c (normalize_to_crlf): Don't ignore
index 41a7373fbab1f39a368433b13109ecc9bbe3a4c3..a77f71b2c1345a73e83c64d1ccdf3f889f98411e 100644 (file)
@@ -33,8 +33,8 @@
 #include <atk/atk.h>
 
 #include "gtkvolumebutton.h"
-#include "gtktooltips.h"
 #include "gtkstock.h"
+#include "gtktooltip.h"
 
 #include "gtkalias.h"
 
 struct _GtkVolumeButton
 {
   GtkScaleButton  parent;
-  GtkTooltips    *tooltips;
 };
 
 static void    gtk_volume_button_class_init    (GtkVolumeButtonClass *klass);
 static void    gtk_volume_button_init          (GtkVolumeButton      *button);
-static void    gtk_volume_button_dispose       (GObject *object);
-static void    gtk_volume_button_update_tooltip(GtkVolumeButton *button);
+static gboolean        cb_query_tooltip                (GtkWidget            *button,
+                                                gint                  x,
+                                                gint                  y,
+                                                gboolean              keyboard_mode,
+                                                GtkTooltip           *tooltip,
+                                                gpointer              user_data);
 static void    cb_value_changed                (GtkVolumeButton      *button,
                                                 gdouble               value,
                                                 gpointer              user_data);
@@ -59,9 +62,6 @@ G_DEFINE_TYPE (GtkVolumeButton, gtk_volume_button, GTK_TYPE_SCALE_BUTTON)
 static void
 gtk_volume_button_class_init (GtkVolumeButtonClass *klass)
 {
-  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
-  gobject_class->dispose = gtk_volume_button_dispose;
 }
 
 static void
@@ -90,30 +90,15 @@ gtk_volume_button_init (GtkVolumeButton *button)
   g_object_set (G_OBJECT (button),
                "adjustment", adj,
                "size", GTK_ICON_SIZE_SMALL_TOOLBAR,
+               "has-tooltip", TRUE,
                NULL);
 
-  button->tooltips = gtk_tooltips_new ();
-  g_object_ref_sink (button->tooltips);
-  gtk_volume_button_update_tooltip (button);
-
+  g_signal_connect (G_OBJECT (button), "query-tooltip",
+                   G_CALLBACK (cb_query_tooltip), NULL);
   g_signal_connect (G_OBJECT (button), "value-changed",
                    G_CALLBACK (cb_value_changed), NULL);
 }
 
-static void
-gtk_volume_button_dispose (GObject *object)
-{
-  GtkVolumeButton *button;
-
-  button = GTK_VOLUME_BUTTON (object);
-
-  if (button->tooltips)
-    g_object_unref (button->tooltips);
-  button->tooltips = NULL;
-
-  G_OBJECT_CLASS (gtk_volume_button_parent_class)->dispose (object);
-}
-
 /**
  * gtk_volume_button_new
  *
@@ -133,8 +118,13 @@ gtk_volume_button_new (void)
   return GTK_WIDGET (button);
 }
 
-static void
-gtk_volume_button_update_tooltip (GtkVolumeButton *button)
+static gboolean
+cb_query_tooltip (GtkWidget  *button,
+                 gint        x,
+                 gint        y,
+                 gboolean    keyboard_mode,
+                 GtkTooltip *tooltip,
+                 gpointer    user_data)
 {
   GtkScaleButton *scale_button = GTK_SCALE_BUTTON (button);
   GtkAdjustment *adj;
@@ -168,16 +158,16 @@ gtk_volume_button_update_tooltip (GtkVolumeButton *button)
       str = g_strdup_printf (Q_("volume percentage|%d %%"), percent);
     }
 
-  gtk_tooltips_set_tip (button->tooltips,
-                       GTK_WIDGET (button),
-                       str, NULL);
+  gtk_tooltip_set_text (tooltip, str);
   g_free (str);
+
+  return TRUE;
 }
 
 static void
 cb_value_changed (GtkVolumeButton *button, gdouble value, gpointer user_data)
 {
-  gtk_volume_button_update_tooltip (button);
+  gtk_widget_trigger_tooltip_query (GTK_WIDGET (button));
 }